<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/skin/default/skin.css}" id="skin"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/laypage/1.2/skin/laypage.css}">
    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layer/2.4/layer.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui/js/H-ui.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui.admin/js/H-ui.admin.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
    <script th:src="@{/static/lib/vue.min.js}"></script>
    <script th:src="@{/static/js/laypage/laypage.js}"></script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 会员管理 <span class="c-gray en">&gt;</span> 会员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <input type="text" class="input-text" style="width:250px" placeholder="输入会员名" id="userName">
        <button type="button" class="btn btn-success radius" id="vip"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"></span> <span class="r">共有数据：<strong id="total"></strong> 条</span> </div>
    <div class="mt-20" id="app">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th width="80">序号</th>
                <th>用户名</th>
                <th>性别</th>
                <th>会员到期时间</th>
                <td id="huiyuan">会员状态</td>
                <td>QQ号</td>
                <td>微信号</td>
                <td>邮箱</td>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c" v-for="(item,index) in result">
                <td><input type="checkbox" value="" name=""></td>
                <td>{{index+1}}</td>
                <td>{{item.userName}}</td>
                <td>{{item.userGender>0?'男':'女'}}</td>
                <td>{{item.userVipdue}}</td>
                <td>{{item.userState>0?'禁用':'正常'}}</td>
                <td>{{item.userQq}}</td>
                <td>{{item.userWeixin}}</td>
                <td>{{item.userEmail}}</td>
                <td class="f-14 td-manage"><a style="text-decoration:none" v-if="item.userState==1" class="ml-5" @click="refuse(item.userId)" title="禁用"><i class="Hui-iconfont">&#xe631;</i></a>
                    <a a style="text-decoration:none" v-if="item.userState==0" @click="succ(item.userId)" class="ml-5" title="启用"><i class="Hui-iconfont">&#xe615;</i></a>
                </td>

            </tr>
            </tbody>
        </table>
        <div id="pagenav"></div>
    </div>
</div>
</body>
<script th:inline="javascript">


    var app = new Vue({
        el: '#app',
        data: {
            result: []
        }
    });


    var getAllVipPages = function (curr) {
        $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url: '/user/getVipList',
            data: {
                pageNum: curr || 1,
                pageSize: 2,
                userName:$("#userName").val()
            },

            success: function (result) {
                app.result = result.page.list;
                console.log(result.page.list)
                var pages=result.total;
                $("#total").html(pages)
                laypage({
                    cont: 'pagenav',
                    skin: '#008B8B',
                    pages: result.pages,
                    first: "首页",
                    last: "尾页",
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getAllVipPages(obj.curr)
                        }
                    }
                });
            }
        });
    }
    getAllVipPages();
    $("#vip").click(function () {
        getAllVipPages();
    });

    /*禁用 用户*/
    var succ = function (userId) {
        layer.confirm('确认要禁用此用户吗？',function(index){
        $.ajax({
            url: "/user/jinyong",
            type: 'post',
            dataType: 'json',
            data: {
                userId: userId,

            },
            success: function (data) {
                location.replace(location.href)
            }
        })
        })
    }
    /*恢复用户正常状态*/
    var refuse = function (userId) {
        layer.confirm('确认要恢复用户正常状态吗',function(index){
        $.ajax({
            url:"/user/qiyong",
            type: 'post',
            dataType: 'json',
            data: {
                userId: userId,
            },
            success: function (data) {
                location.replace(location.href)
            }
        })
        })
    }


</script>
</html>